app.controller('appLogCtrl', ['$rootScope', '$scope', 'httpLoad', '$modal', '$stateParams', '$state',function ($rootScope, $scope, httpLoad, $modal, $stateParams, $state) {
    $scope.getData = function(){
        httpLoad.loadData({
            url: '/pipeline/pipeline/getTaskEvent',
            data: {taskId:$rootScope.taskID},
            success: function (data) {
                if (data.success) {
                    $scope.eventList = data.data;
                }
            }
        })
    };
    $scope.eventLog = function(id){
        var modalInstance = $modal.open({
            templateUrl : '/statics/tpl/application/create/eventLog.html',
            controller : 'eventLogModalCtrl',
            resolve : {
                id: function() {
                    return  id;
                }
            }
        });
        modalInstance.result.then(function(){
        },function(){});
    };
}])
//事件日志ctrl
angular.module('app').controller('eventLogModalCtrl',['$scope','$modalInstance','LANGUAGE','httpLoad','id',
    function($scope,$modalInstance,LANGUAGE,httpLoad,id){ //依赖于modalInstance
        httpLoad.loadData({
            url:'/pipeline/pipeline/eventLogOutput',
            data:{eventId: id},
            success:function(data){
                if(data.success){
                    $scope.codeMirror.setValue(data.data);
                }else{
                    $scope.pop(data.message);
                }
            }
        });
        $scope.cancel = function(){
            $modalInstance.dismiss('cancel'); // 退出
        }
    }]);
app.directive('ngCodeMirror1', [function () {
    return {
        restrict: 'EA',
        scope:{
            codeMirror: '='
        },
        link: function (scope, element, attrs) {
            var editor = $(element).find('.textarea')[0];
            //初始化在线代码编辑器
            var codeMirror = CodeMirror.fromTextArea(editor, {
                theme: 'erlang-dark',
                readOnly: true
            });
            scope.codeMirror = codeMirror;
        }
    }
}]);